package com.xxx.video.main.adapters;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.xxx.video.R;
import com.xxx.video.commen.adapters.BaseRecycleViewAdapter;
import com.xxx.video.commen.adapters.BaseViewHolder;
import com.xxx.video.commen.utils.ResourcesUtils;
import com.xxx.video.commen.utils.StringUtils;
import com.xxx.video.main.beans.DynamicInfoBean;

import butterknife.BindView;

public class DynamicDetailsCommentAdapter extends BaseRecycleViewAdapter<DynamicInfoBean.InteractionListBean, DynamicDetailsCommentAdapter.MyHolder> {

    public DynamicDetailsCommentAdapter(@NonNull Context context) {
        super(context);
    }

    @Override
    public MyHolder onCreateDefaultViewHolder(View view, int viewType) {
        return new MyHolder(view);
    }

    @Override
    public int getItemLayout(int viewType) {
        return R.layout.item_video_details_comment_list;
    }

    class MyHolder extends BaseViewHolder {
        @BindView(R.id.iv_item_video_details_comment_list_avatar)
        ImageView ivItemVideoDetailsCommentListAvatar;
        @BindView(R.id.tv_item_video_details_comment_list_name)
        TextView tvItemVideoDetailsCommentListName;
        @BindView(R.id.tv_item_video_details_comment_list_time)
        TextView tvItemVideoDetailsCommentListTime;
        @BindView(R.id.tv_item_video_details_comment_list_content)
        TextView tvItemVideoDetailsCommentListContent;

        public MyHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void setData2View(int position) {
            DynamicInfoBean.InteractionListBean listBean = getItem(position);
            /*
             * init avatar
             */
            Glide.with(context).load(ResourcesUtils.getInstance().getImagePath(listBean.fCommtenterPicurl)).apply(new RequestOptions().circleCrop()
                    .placeholder(R.drawable.icon_default_avatar)
                    .error(R.drawable.icon_default_avatar)
            ).into(ivItemVideoDetailsCommentListAvatar);
            /*
             * name
             */
            tvItemVideoDetailsCommentListName.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.fCommtenterName));
            /*
             * time
             */
            tvItemVideoDetailsCommentListTime.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.fCreateTime));
            /*
             * content
             */
            tvItemVideoDetailsCommentListContent.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.fComment));
        }
    }
}
